package com.xbongbong.pro.message.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.PlatFormEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Description: 消息分组枚举
 * @author 李杰
 * @date 2019/1/8 10:41
 * @since
 * Modified by:
 */

@Getter
public enum MessageGroupTypeEnum {

    /**
     * 系统通知
     */
    SYSTEM_MESSAGE(1, "enum.messageGroupType.name.system_message", "systemMessage", "web-icon-xitongtongzhi-xiaoxi", "app-icon-xitongtongzhi-xiaoxi", "#FF8E3D"),
    AI_ASSISTANT(2, "enum.messageGroupType.name.ai_assistant", "aiAssistant", "web-icon-SFA-xiaoxi", "app-icon-SFA-xiaoxi", "#FF8E3D"),
    WORK_FLOW(3, "enum.messageGroupType.name.work_flow", "workFlow", "web-icon-gongzuoliu-xiaoxi1", "app-icon-gongzuoliu-xiaoxi1", "#7ED321"),
    CRM(4, "enum.messageGroupType.name.crm", "CRM", "icon-crm", "icon-crm", "#579BF3"),
    JXC(5, "enum.messageGroupType.name.jxc", "JXC", "icon-jxc", "icon-jxc", "#579BF3"),
    FUND_MANAGEMENT(6, "enum.messageGroupType.name.fund_management", "fundManagement", "icon-fundManagement", "icon-fundManagement", "#EE7D71"),
    WORK_ORDER(7, "enum.messageGroupType.name.work_order", "workOrder", "icon-workOrder", "icon-workOrder", "#FF8E3D"),
    MARKET_ACTIVITY(8, "enum.messageGroupType.name.market_activity", "marketActivity", "icon-returnedPurchase", "icon-returnedPurchase", "#F59C44"),
//    CALL_CENTER(8, "呼叫中心", "callCenter", "icon-callCenter", "icon-callCenter", "#EE7D71"),
//    MASS_MESSAGE(9, "短信群发", "massMessage", "", ""),
    DATA_CENTER(11, "enum.messageGroupType.name.data_center", "dataCenter", "icon-fengxianjiankong", "icon-fengxianjiankong", "#F59C44"),
    DISTRIBUTOR(10, "enum.messageGroupType.name.distributor", "distributor", "icon-distributor", "icon-distributor", "#FF8E3D"),
    //AI销小帮
    AI_CENTER(12, "enum.messageGroupType.name.ai_center", "aiCenter", "icon-returnedPurchase", "icon-returnedPurchase","#F59C44"),
    MARKETING_MANAGEMENT(32, "enum.messageGroupType.name.marketing_management", "marketingManagement", "icon-workOrder", "icon-workOrder", "#FFBF00"),
    DISTRIBUTOR_MARKETING_MANAGEMENT(33, "enum.messageGroupType.name.distributor_marketing_management", "marketingManagement", "icon-workOrder", "icon-workOrder", "#FFBF00"),
    // 厂商端订单中心
    ORDER_CENTER(30, "enum.messageGroupType.name.order_center", "orderCenter", "icon-orderCenter", "icon-orderCenter", "#FFBF00"),
    //经销商端订单中心
    DISTRIBUTOR_ORDER_CENTER(31, "enum.messageGroupType.name.distributor_order_center", "orderCenter", "icon-orderCenter", "icon-distributorOrderCenter", "#FFBF00"),
    // 经销商资金管理
    DISTRIBUTOR_FUND_MANAGEMENT(40, "enum.messageGroupType.name.fund_management", "fundManagement", "icon-fundManagement", "icon-fundManagement", "#EE7D71"),
    //新工单
    WORK_ORDER_V2(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), "enum.messageGroupType.name.work_order_v2", "workOrderV2Center","icon-fundManagement", "icon-fundManagement", "#EE7D71"),
    REMIND_MESSAGE(20, "enum.messageGroupType.name.remind_message", "remind_message", "", "app-icon-huifu","#FFBF00")
    ;

    /**
     * 枚举值 表示所属模块
     */
    private final int code;

    /**
     * 枚举名称
     */
    private final String name;
    /**
     * 枚举英文名
     */
    private final String alias;

    /**
     * 应用图标
     */
    private final String webIcon;

    private final String appIcon;

    /**
     * 图标颜色
     */
    private final String color;

    MessageGroupTypeEnum(int code, String name, String alias, String webIcon, String appIcon, String color) {
        this.code = code;
        this.name = name;
        this.alias = alias;
        this.webIcon = webIcon;
        this.appIcon = appIcon;
        this.color = color;
    }

    /**
     * 返回当前语言环境下的名称
     * @return 当前语言环境下的名称
     */
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    /**
     * Description: 根据code获取名称
     * @param code
     * @return java.lang.String
     * @throws
     * @author 李杰
     * @date 2019/1/10 11:07
     * @version
     * @since
     * Modified by:
     */
    public static String getNameByCode(Integer code) {
        for (MessageGroupTypeEnum cache : values()) {
            if (Objects.equals(cache.getCode(), code)) {
                return cache.getName();
            }
        }
        return null;
    }

    /**
     * Description: 根据code获取枚举对象
     * @param code
     * @return com.xbongbong.pro.message.enums.MessageGroupTypeEnum
     * @throws
     * @author 李杰
     * @date 2019/1/10 16:22
     * @version
     * @since
     * Modified by:
     */
    public static MessageGroupTypeEnum getEnumByCode(Integer code) {
        for (MessageGroupTypeEnum cache : values()) {
            if (Objects.equals(cache.getCode(), code)) {
                return cache;
            }
        }
        return null;
    }

    /**
     * Description: 根据平台获取枚举
     * @param platform
     * @return java.util.List<com.xbongbong.pro.message.enums.MessageGroupTypeEnum>
     * @throws
     * @author 李杰
     * @date 2019/1/10 11:11
     * @version
     * @since
     * Modified by:
     */
    public static List<MessageGroupTypeEnum> getEnumByPlatform(String platform) {
        List<MessageGroupTypeEnum> messageGroupTypeEnums = new ArrayList<>();
        for (MessageGroupTypeEnum cache : values()) {
            if (Objects.equals(platform, PlatFormEnum.WEB.getValue()) && Objects.equals(cache, MessageGroupTypeEnum.REMIND_MESSAGE)) {
                continue;
            }
            messageGroupTypeEnums.add(cache);
        }
        return messageGroupTypeEnums;
    }
}
